<template>
	<div>
		<h1>用户管理--修改用户</h1>
		<font color="red">{{msg}}</font><br />
		<table border="1" width="60%" align="center">
			<tr>
				<td>用户名</td>
				<td>
					<input type="text" v-model="user.uname"/>
				</td>
			</tr>
			<tr>
				<td>密码</td>
				<td>
					<input type="password" v-model="user.pass"/>
				</td>
			</tr>
			<tr>
				<td>真实姓名</td>
				<td>
					<input type="text" v-model="user.realname"/>
				</td>
			</tr>
			<tr>
				<td>出生日期</td>
				<td>
					<input type="text" v-model="user.birthdate"/>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<button @click="doUpdate()">修改</button>
				</td>
			</tr>
		</table>
		<br />
	</div>
</template>

<script>
	export default{
		name:'UserUpdate',
		data(){
			return{
				user:{},
				msg:'',
					}
				},
		mounted(){
			this.user=this.$route.query.user;
		},
		methods:{
			doUpdate(){
				// let url='/UserController';
				let url='/user/update';
				this.user.act='update';
				let param=this.$qs.stringify(this.user);
				this.$axios.post(url,param)
				.then((resp)=>{
					let i =resp.data;
					if(i>0){
						this.$router.push('/user/query')
					}else{
						this.msg='修改失败，请处理'
					}
				})
				.catch((err)=>{
					console.log('error=',err);
				})
			}
		}
	}
</script>
<!-- scoped="scoped"表示当前样式属于局部样式，只在当前组件中有效-->
<style scoped="scoped">
	div{
		width: 100%;
		margin: 0 auto;
		text-align: center;
	}
</style>
